//
//  HXTalentCell.m
//  ZCooking
//
//  Created by 韩旭 on 16/8/31.
//  Copyright © 2016年 HX_. All rights reserved.
//

#import "HXTalentCell.h"
#import "HXTalentCustomCell.h"
#import "HX_Macro.h"
#import "UIView+Frame.h"
#import "HXCustomModel.h"
#import "UIImageView+WebCache.h"
#import "HXCustomTitlesModel.h"
@implementation HXTalentCell
- (void)setArrImageHeader:(NSMutableArray *)arrImageHeader {
    _arrImageHeader = arrImageHeader;
    [_tabelView reloadData];
}
- (void)setTitles:(NSMutableArray *)titles {
    _titles = titles;
}
- (void)setUp {
    self.tabelView = [[UITableView alloc] initWithFrame:CGRectZero style:0];
    _tabelView.delegate = self;
    _tabelView.dataSource = self;
    _tabelView.bounces = NO;
    [self.contentView addSubview:_tabelView];
    [_tabelView registerNib:[UINib nibWithNibName:@"HXTalentCustomCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"talent"];
    self.viewLine = [[UIView alloc] init];
    self.viewLine.backgroundColor = [UIColor colorWithRed:0.88 green:0.88 blue:0.88 alpha:1.00];
    [self.contentView addSubview:_viewLine];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 3;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    HXTalentCustomCell *cell = [tableView dequeueReusableCellWithIdentifier:@"talent"];
    _tabelView.separatorStyle = 0;
    HXCustomModel *model = self.arrImageHeader[indexPath.row];
    [cell.imageHeader sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@", model.image]]];
    if (indexPath.row == 0) {
        cell.lineViewOne.priority = 999;
        cell.titleName.text = [[self.titles objectAtIndex:0] text];
        cell.detail.text = [[self.titles objectAtIndex:1] text];
        cell.starch.text = [[self.titles objectAtIndex:2] text];
    } else if (indexPath.row == 1) {
        cell.titleName.text = [[self.titles objectAtIndex:3] text];
        cell.detail.text = [[self.titles objectAtIndex:4] text];
        cell.starch.text = [[self.titles objectAtIndex:5]text];
    } else {
        
        cell.titleName.text = [[self.titles objectAtIndex:6] text];
        cell.detail.text = [[self.titles objectAtIndex:7]text];
        cell.starch.text = [[self.titles objectAtIndex:8] text];
    }
    return cell;
}
- (void)layoutSubviews {
    [super layoutSubviews];
    self.tabelView.frame = CGRectMake(0, 0, self.contentView.bounds.size.width, self.contentView.bounds.size.height - 15);
    self.viewLine.frame = CGRectMake(0, _tabelView.HX_height, SCREEN_WIDTH, 15);
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 100;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    self.rows(indexPath.row);
}
@end
